import { ref } from 'vue';

export default function useLoading(initValue = false) {
	const loading = ref(initValue);
	const setLoading = (value : boolean) => {
		if (value) {
			uni.showLoading()
		} else {
			uni.hideLoading()
		}
		loading.value = value;
	};
	const toggle = () => {
		loading.value = !loading.value;
	};
	return {
		loading,
		setLoading,
		toggle,
	};
}